@extends('steward.layoutEdit')

@section('css')
    <link  rel="stylesheet" href="/static/css/steward/order/order.css?v=20171012123123371">
    <link  rel="stylesheet" href="/static/css/steward/order/detail.css?v=201710170113578">
@endsection

@section('title')
    <li class="cur">
        <span>订单详情</span>
    </li>
@endsection

@section('go-back-btn')
    <button class="btn btn-default layer-go-back" type="button">返回</button>
@endsection

@section('content')
    <div class="order-content">
        <ul class="order-list order-list-detail">
            <li>
                <div class="order-info">
                    <div class="left-info">
                        <div class="left-item">
                            <div class="top-item">
                                @if(!empty($billPlatform_logo))
                                    <span><img src="{{$billPlatform_logo}}"/></span>
                                @endif
                                @if(!empty($ziti_logo))
                                    <span><img src="{{$ziti_logo}}"/></span>
                                @endif
                                <span class="order-num">订单号：<em class="word-color">{{$bill_no}}</em></span>
                            </div>
                            @if(isset($deliver_time))
                                <div class="focus-th">期望提货时间：  {{$deliver_time}}</div>
                            @endif
                        </div>

                        <p class="notice">备注：{{$remark}}</p>
                    </div>

                    <div class="right-info">

                        <div class="word-color">
                        @if($hang_up==1)
                        <div class="order-top-right" id="status">异常单</div>
                        @else
                            <div class="order-top-right" id="status">{{$bill_status_name}}</div>
                        @endif
                        </div>

                        <div class="submit-btn">

                            @if(in_array(7,$button))
                                <select class="form-control reminder" style="display: inline-block;width:120px;">
                                    <option value="">选择内容</option>
                                    @for($i = 0; $i < count($remind_reply); $i++)
                                        <option value="{{$i}}">{{$remind_reply[$i]}}</option>
                                    @endfor
                                </select>
                                <button class="btn btn-default btn-color" data="{{$bill_no}}" id="remindReply" type="button">回复用户</button>
                            @endif

                                @if(in_array(8,$button))
                                    <select class="form-control cancel_reasons" name="search_state" style="width: 150px;display: inline-block;">
                                        <option value="">选择取消内容</option>
                                        @if(isset($reasons) && !empty($reasons))
                                            @foreach($reasons as $reason)
                                                <option value="{{$reason['reasonId']}}">{{$reason['reasonContent']}}</option>
                                            @endforeach
                                        @endif
                                    </select>
                                    <button class="btn btn-primary" data="{{$bill_no}}" id="cancel" type="button">取消</button>
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="receive" type="button">接单</button>
                                @endif

                                @if(in_array(10,$button))
                                    <select class="form-control select" name="search_state" style="width: 135px;display: inline-block;">
                                        <option value="">选择配送平台</option>
                                        @foreach($express_array as $express)
                                            <option value="{{$express['id']}}">{{$express['name']}}</option>
                                        @endforeach
                                    </select>
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="delivery" type="button">发货</button>
                                @endif

                                @if(in_array(11,$button))
                                    <select class="form-control cancel_reasons" name="search_state" style="width: 150px;display: inline-block;">
                                        <option value="">选择取消内容</option>
                                        @if(isset($reasons) && !empty($reasons))
                                            @foreach($reasons as $reason)
                                                <option value="{{$reason['reasonId']}}">{{$reason['reasonContent']}}</option>
                                            @endforeach
                                        @endif
                                    </select>
                                    <button class="btn btn-primary" data="{{$bill_no}}" id="cancel" type="button">取消</button>

                                @endif

                                @if(in_array(4,$button))
                                    <input type="text" class="form-control refund" placeholder="请输入拒绝原因" style="width: 125px;display: inline-block" id="cancel_reason">
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="disagreRefund" type="button">拒绝</button>
                                @endif


                            @if(in_array(1,$button))
                                <button class="btn btn-primary" data="{{$bill_no}}" id="cancelhang" type="button">取消异常</button>
                            @endif

                             @if(in_array(2,$button))
                                  <button class="btn btn-primary"  type="button">打印</button>
                             @endif

                             @if(in_array(3,$button))
                                  <button class="btn btn-default btn-color" data="{{$bill_no}}" id="hang" type="button">挂起</button>
                             @endif

                             @if(in_array(5,$button))
                                  <button class="btn btn-primary" data="{{$bill_no}}" id="agreRefund"  type="button">同意取消</button>
                              @endif

                             @if(in_array(6,$button))
                                    <button class="btn btn-primary" data="{{$bill_no}}" id="agreRefund"  type="button">同意退款</button>
                              @endif

                                @if(in_array(9,$button))
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="finish" type="button">完成</button>
                                @endif

                                @if(in_array(12,$button))
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="packs" type="button">配货</button>
                                @endif

                                @if(in_array(13,$button))
                                    <button class="btn btn-default btn-color" data="{{$bill_no}}" id="packsFinish" type="button">配货完成</button>
                                @endif



                        </div>


                    </div>
                </div>
            </li>
        </ul>



        <div class="order-detail-content">
            <div class="shop-list">
                <div class="body-title">商品清单（{{$goods_num}}）</div>
                <ul class="shop-tab" style="overflow:hidden;">
                    <li>
                        <span class="top-th" style="width: 250px;">商品</span>
                        <span class="top-th">规格</span>
                        <span class="top-th">单价</span>
                        <span class="top-th">数量</span>
                        <span class="top-th">小计</span>
                    </li>
                    @foreach($goods_list as $g_k=>$g_v)
                        <li>
                            <div class="list-shop-li"  style="width: 250px;">
                                <div class="goods-pic goods-item"><span><img src="{{$g_v['img_url']}}" width="80px;" height="80px;"></span></div>
                                <div class="goods-name goods-item"><span>{{$g_v['goods_name']}}</span></div>
                            </div>
                            <div class="list-shop-li">
                                <div class="goods-pic goods-item"><span>{{$g_v['goods_spec']}}</span></div>
                            </div>
                            <div class="list-shop-li">
                                <div class="goods-pic goods-item"><span>￥{{$g_v['goods_purchasePrice']}}</span></div>
                            </div>
                            <div class="list-shop-li">
                                <div class="goods-pic goods-item"><span>{{$g_v['goods_amount']}}</span></div>
                            </div>
                            <div class="list-shop-li">
                                <div class="goods-pic goods-item"><span>￥{{$g_v['goodsprice']}}</span></div>
                            </div>
                        </li>
                    @endforeach
                </ul>
                <div class="total">
                    <p>
                        <span class="text">商品金额</span>
                        <span class="value">￥{{$bill_payable}}</span>
                    </p>
                    <p>
                        <span class="text">运费</span>
                        <span class="value">￥{{$deliver_fee}}</span>
                    </p>
                    <p>
                        <span class="text">优惠金额</span>
                        <span class="value">￥-{{$bill_cut_money}}</span>
                    </p>
                    <p>
                        <span class="text">已付金额</span>
                        <span class="value word-color">￥{{$bill_payable}}</span>
                    </p>
                </div>

            </div>
            <div class="cart-list">
                <div class="body-title">配送信息</div>
                <div class="distru-box">
                    <p><span class="name">{{$delivery_arr['deliver_name']}}</span><span class="word-color">第{{$ordernum}}次下单</span></p>
                    <p><span class="phone">{{$delivery_arr['deliver_mobile']}}</span></p>
                    <p class="address">{{$delivery_arr['deliver_address']}}</p>
                </div>
                <div class="logistics">
                    <ul class="logistics-list">
                        @foreach($trace_arr as $t_k=>$t_v)
                            @if($t_k==($trace_num-1))
                                <li class="on">
                                    <span class="border-line-top"></span>
                                    <span class="border-line-bot"></span>
                                    <span class="circle"></span>
                                    <div class="text-box">
                                        <p class="active">{{$t_v['content']}}</p>
                                        <p class="gray-text-sm active">操作人：{{$t_v['creator']}}</p>
                                        <p class="gray-text-sm">{{$t_v['createTime']}}</p>
                                    </div>
                                </li>
                            @else

                                <li>
                                    <span class="border-line-top"></span>
                                    <span class="border-line-bot"></span>
                                    <span class="circle"></span>
                                    <div class="text-box">
                                        <p class="active">{{$t_v['content']}}</p>
                                        <p class="gray-text-sm active">操作人：{{$t_v['creator']}}</p>
                                        <p class="gray-text-sm">{{$t_v['createTime']}}</p>
                                    </div>
                                </li>
                                @endif

                        @endforeach
                    </ul>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script>
        //挂起
        $(document).on('click','#hang',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/hang',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //取消挂起
        $(document).on('click','#cancelhang',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/cancel_hang',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //接单
        $(document).on('click','#receive',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/receive',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //取消
        $(document).on('click','#cancel',function(){
            var val = $(this).parent('div').find("option:selected").text();
            var reason_id = $(this).parent('div').find("option:selected").val();
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/cancel',
                data:{
                    bill_no:bill_no,
                    reason:val,
                    reasonId:reason_id
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });

        //配货
        $(document).on('click','#packs',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/packs',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        var html='<button class="btn btn-default btn-color" data="'+bill_no+'" id="packsFinish" type="button">配货完成</button>';
                        $('.packs').html(html);
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //配货完成
        $(document).on('click','#packsFinish',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/packs_finish',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //发货
        $(document).on('click','#delivery',function(){
            var express_id = $(this).parent('div').find("option:selected").val();
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/delivery',
                data:{
                    bill_no:bill_no,
                    express_id:express_id
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                       var html=' <button class="btn btn-default btn-color" data="'+bill_no+'" id="finish" type="button">完成</button>';
                       $('.delivery').html(html);
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })
        });
//回复用户
        $(document).on('click','#remindReply',function(){
            var reply_message = $(this).parent('div').find("option:selected").text();
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/remind_reply',
                data:{
                    bill_no:bill_no,
                    reply_message:reply_message
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                       _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })
        });
//同意取消/退款
        $(document).on('click','#agreRefund',function(){
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/agre_refund',
                data:{
                    bill_no:bill_no
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });
        //拒绝
        $(document).on('click','#disagreRefund',function(){
            var cancel_reason=$("#cancel_reason").val();
            var _this=$(this);
            var bill_no=$(this).attr('data');
            $.ajax({
                type: "post",
                dataType: "json",
                url: '/lar/steward/order/disagre_refund',
                data:{
                    bill_no:bill_no,
                    cancel_reason:cancel_reason
                },
                success: function (msg) {
                    if(msg.code==200)
                    {
                        layer.msg( msg.message , {icon: 1,shade: [0.15, 'black'],offset:'120px',time:1000});
                        _this.remove();
                    }else{
                        layer.msg(  msg.message  , {icon: 2,shade: [0.15, 'black'],offset:'120px',time:1000});
                    }
                }
            })

        });


    </script>

@endsection